package com.nuoniu.sibanyun.controller.system;

import com.nuoniu.sibanyun.common.result.HttpResult;
import com.nuoniu.sibanyun.service.ISysAgreementService;
import com.nuoniu.sibanyun.service.RSA.RsaService;
import com.nuoniu.sibanyun.service.crm.ICrmWebConfigService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName PublicController
 * @Description TODO
 * @Authpr baiqiang
 * @Date 2020/6/4 14:47
 **/
@RestController
@RequestMapping("/public")
@Api(value="公共接口",tags={"公共接口"})
public class PublicController {

    @Autowired
    private RsaService rsaService;

    @Autowired
    private ICrmWebConfigService webConfigService;

    @Autowired
    private ISysAgreementService sysAgreementService;


    @GetMapping("/getPublicKey")
    @ApiOperation(value = "获取公钥" )
    public HttpResult getPublicKey(){
        return HttpResult.ok("获取成功",rsaService.getPublicKey());
    }

    /**
     * 获取登录页配置
     * @return
     */
    @GetMapping("loginConfig")
    @ApiOperation(value = "获取登录页配置" )
    @ApiImplicitParams({
            @ApiImplicitParam(name="shareId", value="分享id"),
    })
    public HttpResult getLoginConfig(Integer shareId){
        return HttpResult.ok(webConfigService.getLoginConfig(shareId));
    }

    /**
     * 获取协议
     * @param code
     * @return
     */
    @GetMapping("getAgreement")
    @ApiOperation(value = "获取协议" )
    @ApiImplicitParams({
            @ApiImplicitParam(name="code",value="协议code(user:用户协议;privacy:隐私协议;share:分享协议;)",required=true,paramType="query"),
    })
    public HttpResult getAgreement(String code){
        return HttpResult.ok("获取成功",sysAgreementService.getAgreement(code));
    }
}
